// ImageProcMatlabPoCApp.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <string>
#include <iostream>
#include <sstream>
#include "engine.h"


int _tmain(int argc, _TCHAR* argv[])
{
	std::cout << "PlayMatlabApp initialised" << std::endl;
	Engine *ep;
	if (!(ep = engOpen("\0")))
	{
		std::cerr << "Can't start MATLAB engine" << std::endl;
		return EXIT_FAILURE;
	}
	 
	const std::string file = "TestMe.m";
	const std::string path = "C:\\users\\yuchen\\Documents\\MATLAB\\";
	std::stringstream SSArg (std::stringstream::in | std::stringstream::out);				//declares stringstream for both i/p and o/p
	SSArg << "path('" << path << "')";
	std::cout << SSArg.str().c_str() << std::endl;
	engEvalString(ep, SSArg.str().c_str());
	SSArg.str("");
	SSArg << "TestMe(" << ")";
	engEvalString(ep, SSArg.str().c_str());

	std::cout << "Type something to quit" << std::endl;
	std:: string s;
	std::getline(std::cin, s);																// pause long enough to be able to see the plot

	engEvalString(ep, "close;");															// close MATLAB figure.
	return 0;
}

